# Maintainer: Christian Rebischke <chris.rebischke@archlinux.org>
# Contributor: sseneca <me at ssene dot ca>
# Contributor: ml <ml@visu.li>

pkgname=kubeseal
_pkgname=sealed-secrets
pkgver=0.24.4
pkgrel=1
pkgdesc="A Kubernetes controller and tool for one-way encrypted Secrets"
arch=('loong64' 'x86_64')
url="https://github.com/bitnami-labs/sealed-secrets"
license=('Apache')
makedepends=('go')
depends=('glibc')
source=("${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha512sums=('c58e78afc9af1c86165fc38a94ee7565fa3eddc98b99cbfc51d0ab231fe7c2ba39ab207a13031993abbe547b68c535998919c82242dd6ade248ee2fc4dd33394')
options=('!lto')

build() {
  cd "${_pkgname}-${pkgver}/cmd/kubeseal"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"

  go build -ldflags="-linkmode=external -X=main.VERSION=v${pkgver}" .
}

check() {
  cd "${_pkgname}-${pkgver}"

  go test ./cmd/kubeseal/... ./pkg/...
}

package() {
  cd "${_pkgname}-${pkgver}/cmd/kubeseal/"

  install -Dm755 "$pkgname" "$pkgdir/usr/bin/$pkgname"
}
